#!/bin/bash

# 要设置的代理
HTTP_PROXY="http://172.20.215.216:7890"
HTTPS_PROXY="http://172.20.215.216:7890"

# 检查并更新或添加代理设置
if grep -q "export http_proxy=" ~/.bashrc; then
    sed -i "s|export http_proxy=.*|export http_proxy='$HTTP_PROXY'|" ~/.bashrc
else
    echo "export http_proxy='$HTTP_PROXY'" >> ~/.bashrc
fi

if grep -q "export https_proxy=" ~/.bashrc; then
    sed -i "s|export https_proxy=.*|export https_proxy='$HTTPS_PROXY'|" ~/.bashrc
else
    echo "export https_proxy='$HTTPS_PROXY'" >> ~/.bashrc
fi

# 重新加载 ~/.bashrc 文件以使更改生效
source ~/.bashrc

